﻿var element, form, $;
layui.use(['layer'], function() {
	$ = layui.jquery;
	GetLastLoginInfo();
	GetCount();
});

//获取登录信息
function GetLastLoginInfo() {
	$.ajax({
		url: apiUrl + 'api/Admin/GetLastLoginInfo?account=' + sessionStorage.getItem("account"),
		type: 'get', //GET
		async: true, //或false,是否异步
		dataType: 'json', //返回的数据格式：json/xml/html/script/jsonp/text
		contentType: 'application/json',
		headers: {
			'Authorization': 'Bearer ' + sessionStorage.getItem("token")
		},
		success: function(jsondata) {
			if(jsondata.Type == 1) {
				var tblog = '<tr><td>' + jsondata.Data.Log_user + '</td><td>' + jsondata.Data.Log_time.replace("T", " ") + '</td><td>' + jsondata.Data.Log_address + '</td><td>' + jsondata.Data.Log_ip + '</td></tr>'
				$("#tbLog").html("").html(tblog);
			}
		},
		statusCode: {
			401: function() {
				layer.msg("登录信息验证失败，请重新登录");
				location.href = 'login.html';
			}
		}

	});
}

//获取数量统计
function GetCount() {
	$.ajax({
		url: apiUrl + 'api/Admin/GetCount',
		type: 'get', //GET
		async: true, //或false,是否异步
		dataType: 'json', //返回的数据格式：json/xml/html/script/jsonp/text
		contentType: 'application/json',
		headers: {
			'Authorization': 'Bearer ' + sessionStorage.getItem("token")
		},
		success: function(jsondata) {
			if(jsondata.Type == 1) {
				$("#spanArticleCount").html(jsondata.Data.articlecount);
				$("#spanResourceCount").html(jsondata.Data.resourcecount);
				$("#spanFuliCount").html(jsondata.Data.fulicount);
			}
		},
		statusCode: {
			401: function() {
				layer.msg("登录信息验证失败，请重新登录");
				location.href = 'login.html';
			}
		}

	});
}